def qfm():
    import tkinter as tk
    fmwindow=tk.Tk()
    fmwindow.title("求反码")
    fmwindow.geometry("650x850")
    def sfhf():
        f=e1.get()
    def szsf():
        s=eval(e2.get())
    def xsqfm():
        f=e1.get()
        s=eval(e2.get())
        s0=s
        sp=[]
        fp=[]
        co=0
        if f=='+':
            if s==0:
                tx.insert('insert',"\n+{0}计算过程：\n0\n00\n".format(s0))
                tx.insert('insert',"+0反码为：\n")
                tx.insert('insert',"00\n")
            else:
                tx.insert('insert',"\n+{0}计算过程：\n".format(s0))
                while s>0:
                    x=s%2
                    sp.append(x)
                    s=s//2
                    tx.insert('insert',"{0}\n".format(sp))
                sp.reverse()
                sp.insert(0,0)
                tx.insert('insert',"+{0}反码为：\n".format(s0))
                tx.insert('insert',"{0}\n".format(sp))
        if f=='-':
            if s==0:
                tx.insert('insert',"\n-{0}计算过程：\n1\n11\n".format(s0))
                tx.insert('insert',"-0反码为：\n")
                tx.insert('insert',"11\n")
            else:
                while s>0:
                    x=s%2
                    sp.append(x)
                    s=s//2
                sp.reverse()
                sp.insert(0,1)
#            print(sp)
                tx.insert('insert',"\n-{0}计算过程：\n".format(s0))
                for i in sp:
                    if co!=0:
                        if i==0:
                            fp.append(1)
                            tx.insert('insert',"{0}\n".format(fp))
                        elif i==1:
                            fp.append(0)
                            tx.insert('insert',"{0}\n".format(fp))
                    elif co==0:
                        fp.append(i)
                        tx.insert('insert',"{0}\n".format(fp))
                    co=co+1
                tx.insert('insert',"\n-{0}反码为：\n".format(s0))
                tx.insert('insert',"{0}\n".format(fp))
    lb1=tk.Label(fmwindow, text='输入整数的符号（+/-）', bg='orange', font=('Arial', 12), width=30)
    lb1.pack()
    e1 = tk.Entry(fmwindow,font=('Arial', 14))
    e1.pack()
    bt1=tk.Button(fmwindow,text='确认符号',width=10,font=('Arial', 12),command=sfhf)
    bt1.pack()
    
    lb2=tk.Label(fmwindow, text='输入整数（不带符号）', bg='orange', font=('Arial', 12), width=30)
    lb2.pack()
    e2 = tk.Entry(fmwindow,font=('Arial', 14))
    e2.pack()
    bt2=tk.Button(fmwindow,text='确认数字',width=10,font=('Arial', 12),command=szsf)
    bt2.pack()
    
    lb3=tk.Label(fmwindow, text='---------------------------------------------', bg='orange', font=('Arial', 12), width=30)
    lb3.pack()
    bt3=tk.Button(fmwindow,text='求解反码',width=10,font=('Arial', 12),command=xsqfm)
    bt3.pack()
    
    lb4=tk.Label(fmwindow, text='结果与过程如下：', bg='orange', font=('Arial', 12), width=30)
    lb4.pack()
    tx=tk.Text(fmwindow,width=85,height=40)
    tx.pack()
    fmwindow.mainloop()